<template>
  <div style="height:570px;;width:100%;position:relative;">
      <div class="pagetop" style="font-size:12px;">
          <table style="float:left; width:600px;">
              <tr>
                  <td>项目类别</td>
                  <td>
                      <rm-ddl-rptitemclass :appendtobody="true" @change="rptitemclasschange" v-model="rptitemclassval" width="100%"></rm-ddl-rptitemclass>
                  </td>
                  <td>项目类别</td>
                  <td>
                      <el-select clearable v-model="medflag" @change="medflagchange" placeholder="请选择" style="width:100%" filterable>
                          <el-option v-for="item in medflagoptions" :key="item.value" :value="item.value" :label="item.label">
                              <span style="float: left">{{ item.label }}</span>
                              <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
                          </el-option>
                      </el-select>
                  </td>
              </tr>
              <tr>
                  <td>快速查找</td>
                  <td>
                      <el-input v-model="qcode" @input="autosearch" clearable ref="qcodeinput"></el-input>
                  </td>
                  <td>仪器大类</td>
                  <td>
                      <rm-ddl-common :appendtobody="true" @change="seccodechange" datatype="seccode" kindno="INSTRCLASS" dataname="仪器大类" v-model="instrclassval" width="100%"></rm-ddl-common>
                  </td>
              </tr>
              <tr>
                  <td>批次输入模板</td>
                  <td colspan="3">
                      <rm-ddl-common dataname="批次输入模板" @change="inputmdlchange" datatype="labinputmdl" v-model="labinputmdlval" width="100%" :appendtobody="true"></rm-ddl-common>
                  </td>
              </tr>
          </table>
          <table style="float:left;padding-left:20px; width:300px;">
              <tr style="height:36px;">
                  <td>
                      <el-button style="height:32px;" @click="btnquery" icon="el-icon-search">查询</el-button>
                  </td>
                  <td>
                      <el-button style="height:32px;width:86px;" @click="clearsearchinput" icon="el-icon-close">清&nbsp;除</el-button>
                  </td>
                  <td>
                      <el-button style="height:32px;" @click="btnok" icon="el-icon-circle-check">确定</el-button>
                  </td>
                  <td>
                      <el-button style="height:32px;" @click="btncancel" icon="el-icon-circle-close">取消</el-button>
                  </td>
              </tr>
              <tr style="height:36px;">
                  <td>
                      <el-button style="height:31px;" @click="btnsel(true)" icon="el-icon-circle-check">全选</el-button>
                  </td>
                  <td>
                      <el-button style="height:31px;width:86px;" @click="btnsel(false)" icon="el-icon-circle-close">全不选</el-button>
                  </td>
                  <td>
                      <el-button style="height:31px;" @click="innerVisible=true" icon="el-icon-sort">排序</el-button>
                  </td>
                  <td>
                      <el-button style="height:31px" @click="refreshdata" icon="el-icon-refresh">刷新</el-button>
                  </td>
              </tr>
          </table>
      </div>
      <div style=" clear:both"></div>
      <div class="pagecenter" style=" height: 486px">
          <vxe-grid :data="sortdata" :columns="tableColumn" :loading="loading" :pager-config="tablePage" sortable :proxy-config="tableProxy" border height="486px" highlight-current-row show-overflow highlight-hover-row ref="ddlCommonTable" resizable size="mini" stripe header-align="center" :sort-config="{trigger: 'cell'}"></vxe-grid>
          <!-- :select-config="selectConfig"  -->
      </div>
      <el-dialog width="40%" title="排序" :visible.sync="innerVisible" append-to-body>
          <div>
              <vxe-table :data.sync="tableDates" border style="width: 100%" height="300" :mouse-config="{selected: true}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true}" show-header-overflow="tooltip" show-overflow="tooltip" highlight-current-row highlight-hover-row resizable size="mini" ref="ddlCommonTableSort">
                  <vxe-table-column field="sortcolumn" title="排序栏" width="200">
                      <template v-slot="{row}">
                          <el-select @focus="clkselect" v-model="row.sortcolumn">
                              <el-option v-for="item in getsortoptions" :value="item.field" :key="item.field" :label="item.title"></el-option>
                          </el-select>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="defaultsort" title="排序选择" show-overflow-tooltip width="200" align="center">
                      <template v-slot="{row}">
                          <el-radio v-model="row.defaultsort" label="1">升序</el-radio>
                          <el-radio v-model="row.defaultsort" label="2">降序</el-radio>
                      </template>
                  </vxe-table-column>

              </vxe-table>
          </div>
          <span slot="footer" class="dialog-footer">
              <el-button icon="el-icon-plus" @click="addsortrecord">新增</el-button>
              <el-button icon="el-icon-minus" @click="delsortrecord">删除</el-button>
              <el-button icon="el-icon-caret-top" @click="insertsortrecord">插入</el-button>
              <el-button icon="el-icon-delete" @click="clearsortrecord">清除</el-button>
              <el-button icon="el-icon-circle-check" @click="savesortrecord">确定</el-button>
              <el-button icon="el-icon-circle-close" @click="innerVisible = false">取消</el-button>
          </span>
      </el-dialog>
  </div>
</template>
<script>
export default {
  props: {
      width: { type: String, default: "200px" },
      value: [Number, String],
      instrid: { type: Number },
      rptUnitReportType: { type: String, default: "10" },
      rptUnitIds: { type: String },
  },
  watch: {
      instrid(newVal) {
          this.myinstrid = newVal;
          if (this.$refs.ddlCommonTable) {
              this.$refs.ddlCommonTable.commitProxy("query");
          }
      },
      rptUnitReportType(newVal) {
          this.reportType = newVal;
          if (this.$refs.ddlCommonTable) {
              this.$refs.ddlCommonTable.commitProxy("query");
          }
      },
  },
  data() {
      return {
          loading: false,
          innerVisible: false,
          medflagoptions: [
              { value: 0, label: "普通项目" },
              { value: 1, label: "培养阴性结果" },
              { value: 5, label: "培养阴性过程" },
              { value: 2, label: "致病菌" },
              { value: 3, label: "正常菌种" },
              { value: 4, label: "涂片结果" },
              { value: 6, label: "基因项目" },
          ],
          medflag: 0,
          rptitemclassval: "",
          myinstrid: this.instrid,
          reportType: this.rptUnitReportType,
          qcode: "",
          instrclassval: "",
          labinputmdlval: "",
          selseccodename: "",
          // selectConfig: {
          //     tigger: "row",
          // },
          defaultsort: "1",
          sortfield: "",
          tableDates: [],
          sortdata: [],
          getsortoptions: [
              { field: "itemcode_en", title: "英文缩写" },
              { field: "rpt_itemname", title: "报告项目名称" },
              { field: "itemtips", title: "项目备注" },
              { field: "itemclassname", title: "项目归类" },
              { field: "instrclassname", title: "仪器类别" },
              { field: "rpt_itemcode", title: "项目代码" },
          ],
          tableColumn: [
              { type: "selection", width: 50, align: "center" },
              { field: "itemcode_en", title: "英文缩写", width: 100, sortable: true },
              { field: "rpt_itemname", title: "报告项目名称", width: 200, sortable: true },
              { field: "itemtips", title: "项目备注", width: 200, sortable: true },
              { field: "itemclassname", title: "项目归类", width: 160, sortable: true },
              { field: "instrclassname", title: "仪器类别", width: 100, sortable: true },
              { field: "rpt_itemcode", title: "项目代码", width: 100, sortable: true },
              { field: "inputcode", title: "输入码", width: 100, sortable: true },
          ],
          tablePage: {
              pageSize: 10000,
          },
          tableProxy: {
              index: true, // 启用动态序号代理
              sort: true,
              // 配置响应的数据属性
              props: {
                  result: "data.result",
                  total: "data.page.total",
              },
              ajax: {
                  query: (param) => {
                      let _this = this;
                      // this.loading = true;
                      return new Promise((s, f) => {
                          let cData = [];
                          if (this.rptUnitIds) {
                              var idarr = this.rptUnitIds.split(",");
                              for (let i = 0; i < idarr.length; i++) {
                                  let data = _this.$ddldata.getrptunititem(idarr[i]);
                                  cData = cData.concat(data._v);
                                  // console.log("cdata" + i, cData);
                              }
                          } else cData = _this.$ddldata.rmallrptitem;
                          //console.log("cdatafinal", cData);
                          try {
                              if (this.reportType == "40") {
                                  cData = cData.filter((item) => item.marrowflag == "1");
                                  if (this.qcode != "") {//骨髓业务类型时也可以快速查询
                                      cData = cData.filter((item) => (item.rpt_itemcode ? item.rpt_itemcode.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false) || (item.rpt_itemname ? item.rpt_itemname.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false) || (item.inputcode ? item.inputcode.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false) || (item.itemcode_en ? item.itemcode_en.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false) || (item.itemname_en ? item.itemname_en.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false));
                                  }
                                  s({ data: { page: { total: cData.length }, result: cData } });
                              } else {
                                  if (this.medflag !== "") {
                                      cData = cData.filter((item) => item.germflagid == this.medflag);
                                  }
                                  if (this.rptitemclassval && this.rptitemclassval != "") {
                                      cData = cData.filter((item) => item.itemclasscode == this.rptitemclassval || item.parentclasscode == this.rptitemclassval);
                                  }
                                  if (this.qcode != "") {
                                      // cData = cData.filter((item) => item.rpt_itemcode.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 || item.rpt_itemname.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 || item.inputcode.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 || (item.itemcode_en ? item.itemcode_en.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false) || (item.itemname_en ? item.itemname_en.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false));
                                      cData = cData.filter((item) => (item.rpt_itemcode ? item.rpt_itemcode.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false) || (item.rpt_itemname ? item.rpt_itemname.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false) || (item.inputcode ? item.inputcode.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false) || (item.itemcode_en ? item.itemcode_en.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false) || (item.itemname_en ? item.itemname_en.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 : false));
                                  }
                                  if (this.instrclassval && this.instrclassval != "") {
                                      cData = cData.filter((item) => item.instrclass == this.instrclassval);
                                  }
                                  if (this.labinputmdlval && this.labinputmdlval != "") {
                                      _this.$ddldata.getinputmdlrptitem().then((r) => {
                                          let inputmdlitem = _this.$ddldata.rminputmdlrptitem;
                                          inputmdlitem = inputmdlitem.filter((item2) => item2.inputmdlid == this.labinputmdlval);
                                          cData = cData.filter((item) => inputmdlitem.filter((item2) => item2.rpt_itemcode == item.rpt_itemcode).length > 0);

                                          if (this.myinstrid && this.myinstrid != 0) {
                                              this.$ddldata.getallinstrItem().then((r) => {
                                                  let instrItem = this.$ddldata.rmInstrItem;
                                                  instrItem = instrItem.filter((item2) => item2.instrid == this.myinstrid);
                                                  cData = cData.filter((item) => instrItem.filter((item2) => item2.rpt_itemcode == item.rpt_itemcode).length > 0);
                                                  s({ data: { page: { total: cData.length }, result: cData } });
                                                  // this.loading = false;
                                              });
                                          } else {
                                              s({ data: { page: { total: cData.length }, result: cData } });
                                              // this.loading = false;
                                          }
                                      });
                                  } else {
                                      if (this.myinstrid && this.myinstrid != 0) {
                                          this.$ddldata.getallinstrItem().then((r) => {
                                              let instrItem = this.$ddldata.rmInstrItem;
                                              instrItem = instrItem.filter((item2) => item2.instrid == this.myinstrid);
                                              cData = cData.filter((item) => instrItem.filter((item2) => item2.rpt_itemcode == item.rpt_itemcode).length > 0);
                                              s({ data: { page: { total: cData.length }, result: cData } });
                                              // this.loading = false;
                                          });
                                      } else {
                                          s({ data: { page: { total: cData.length }, result: cData } });
                                          // this.loading = false;
                                      }
                                  }
                              }
                          } catch (e) {
                              console.log("erro", e);
                              // this.loading = false;
                          }
                      });
                  },
              },
          },
          seloptions: [],
          isbis: false,
      };
  },
  computed: {
      myappendtobody: function () {
          return this.appendtobody;
      },
  },
  updated() {
      if (this.$refs.qcodeinput) {
          this.$refs.qcodeinput.focus();
      }
  },
  created() {
      this.isbis = this.$tool.checkBis();
  },
  mounted() {
      this.loadAllData();
  },
  methods: {
      rptitemclasschange(code, sobj) {
          this.rptitemclassval = code;
          this.$refs.ddlCommonTable.commitProxy("query");
      },
      seccodechange(code, name) {
          this.instrclassval = code;
          this.$refs.ddlCommonTable.commitProxy("query");
      },
      inputmdlchange(c, n) {
          this.labinputmdlval = c;
          this.$refs.ddlCommonTable.commitProxy("query");
      },
      medflagchange() {
          this.$refs.ddlCommonTable.commitProxy("query");
      },
      clearsearchinput() {
          this.rptitemclassval = "";
          this.medflag = 0;
          this.qcode = "";
          this.instrclassval = "";
          this.labinputmdlval = "";
          this.$refs.ddlCommonTable.commitProxy("query");
      },
      autosearch() {
          this.$refs.ddlCommonTable.commitProxy("query");
      },
      addsortrecord() {
          this.$refs.ddlCommonTableSort.insert({ sortcolumn: "", defaultsort: "1" });
      },
      delsortrecord() {
          var delrow = this.$refs.ddlCommonTableSort.getCurrentRow();
          if (delrow) {
              this.$refs.ddlCommonTableSort.remove(delrow);
          } else {
              this.$message({
                  message: "请先选中要删除的排序！",
                  type: "warning",
              });
          }
      },
      insertsortrecord() {
          var crow = this.$refs.ddlCommonTableSort.getCurrentRow();
          if (crow) {
              this.$refs.ddlCommonTableSort.insertAt({ sortcolumn: "", defaultsort: "1" }, crow);
          } else {
              this.$refs.ddlCommonTableSort.insert({ sortcolumn: "", defaultsort: "1" });
          }
      },
      clearsortrecord() {
          this.tableDates = [];
      },
      savesortrecord() {
          this.innerVisible = false;
          let tabledata = this.$refs.ddlCommonTableSort.tableData;
          let popdada = this.$refs.ddlCommonTable.tableData;
          let sortfields = [];
          let sortways = [];
          if (tabledata.length > 0) {
              for (var i = 0; i < tabledata.length; i++) {
                  var sortfield = tabledata[i].sortcolumn;
                  var sortway = tabledata[i].defaultsort;
                  sortfields.push(sortfield);
                  sortways.push(sortway);
              }
          }
          if (tabledata.length == 1) {
              popdada.sort((a, b) => {
                  let value10 = a[sortfields[0]];
                  let value20 = b[sortfields[0]];
                  if (sortways[0] == "1") {
                      //升序
                      return a[sortfields[0]].localeCompare(b[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                  } else {
                      //降序
                      return b[sortfields[0]].localeCompare(a[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                  }
              });
          } else if (tabledata.length == 2) {
              popdada.sort((a, b) => {
                  let value10 = a[sortfields[0]];
                  let value20 = b[sortfields[0]];
                  let value11 = a[sortfields[1]];
                  let value21 = b[sortfields[1]];
                  if (value10 != value20) {
                      if (sortways[0] == "1") {
                          //升序
                          return a[sortfields[0]].localeCompare(b[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      } else {
                          //降序
                          return b[sortfields[0]].localeCompare(a[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      }
                  } else {
                      if (sortways[1] == "1") {
                          //升序
                          return a[sortfields[1]].localeCompare(b[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                      } else {
                          //降序
                          return b[sortfields[1]].localeCompare(a[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                      }
                  }
              });
          } else if (tabledata.length == 3) {
              popdada.sort((a, b) => {
                  let value10 = a[sortfields[0]];
                  let value20 = b[sortfields[0]];
                  let value11 = a[sortfields[1]];
                  let value21 = b[sortfields[1]];
                  let value12 = a[sortfields[2]];
                  let value22 = b[sortfields[2]];
                  if (value10 != value20) {
                      if (sortways[0] == "1") {
                          //升序
                          return a[sortfields[0]].localeCompare(b[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      } else {
                          //降序
                          return b[sortfields[0]].localeCompare(a[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      }
                  } else {
                      if (value11 != value21) {
                          if (sortways[1] == "1") {
                              //升序
                              return a[sortfields[1]].localeCompare(b[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                          } else {
                              //降序
                              return b[sortfields[1]].localeCompare(a[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                          }
                      } else {
                          if (sortways[1] == "1") {
                              //升序
                              return a[sortfields[2]].localeCompare(b[sortfields[2]], "zh-Hans-CN", { sensitivity: "accent" });
                          } else {
                              //降序
                              return b[sortfields[2]].localeCompare(a[sortfields[2]], "zh-Hans-CN", { sensitivity: "accent" });
                          }
                      }
                  }
              });
          } else if (tabledata.length == 4) {
              popdada.sort((a, b) => {
                  let value10 = a[sortfields[0]];
                  let value20 = b[sortfields[0]];
                  let value11 = a[sortfields[1]];
                  let value21 = b[sortfields[1]];
                  let value12 = a[sortfields[2]];
                  let value22 = b[sortfields[2]];
                  let value13 = a[sortfields[3]];
                  let value23 = b[sortfields[3]];
                  if (value10 != value20) {
                      if (sortways[0] == "1") {
                          //升序
                          return a[sortfields[0]].localeCompare(b[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      } else {
                          //降序
                          return b[sortfields[0]].localeCompare(a[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      }
                  } else {
                      if (value11 != value21) {
                          if (sortways[1] == "1") {
                              //升序
                              return a[sortfields[1]].localeCompare(b[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                          } else {
                              //降序
                              return b[sortfields[1]].localeCompare(a[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                          }
                      } else {
                          if (value12 != value22) {
                              if (sortways[2] == "1") {
                                  //升序
                                  return a[sortfields[2]].localeCompare(b[sortfields[2]], "zh-Hans-CN", { sensitivity: "accent" });
                              } else {
                                  //降序
                                  return b[sortfields[2]].localeCompare(a[sortfields[2]], "zh-Hans-CN", { sensitivity: "accent" });
                              }
                          } else {
                              if (sortways[3] == "1") {
                                  //升序
                                  return a[sortfields[3]].localeCompare(b[sortfields[3]], "zh-Hans-CN", { sensitivity: "accent" });
                              } else {
                                  //降序
                                  return b[sortfields[3]].localeCompare(a[sortfields[3]], "zh-Hans-CN", { sensitivity: "accent" });
                              }
                          }
                      }
                  }
              });
          } else if (tabledata.length == 5) {
              popdada.sort((a, b) => {
                  let value10 = a[sortfields[0]];
                  let value20 = b[sortfields[0]];
                  let value11 = a[sortfields[1]];
                  let value21 = b[sortfields[1]];
                  let value12 = a[sortfields[2]];
                  let value22 = b[sortfields[2]];
                  let value13 = a[sortfields[3]];
                  let value23 = b[sortfields[3]];
                  let value14 = a[sortfields[4]];
                  let value24 = b[sortfields[4]];
                  if (value10 != value20) {
                      if (sortways[0] == "1") {
                          //升序
                          return a[sortfields[0]].localeCompare(b[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      } else {
                          //降序
                          return b[sortfields[0]].localeCompare(a[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      }
                  } else {
                      if (value11 != value21) {
                          if (sortways[1] == "1") {
                              //升序
                              return a[sortfields[1]].localeCompare(b[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                          } else {
                              //降序
                              return b[sortfields[1]].localeCompare(a[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                          }
                      } else {
                          if (value12 != value22) {
                              if (sortways[2] == "1") {
                                  //升序
                                  return a[sortfields[2]].localeCompare(b[sortfields[2]], "zh-Hans-CN", { sensitivity: "accent" });
                              } else {
                                  //降序
                                  return b[sortfields[2]].localeCompare(a[sortfields[2]], "zh-Hans-CN", { sensitivity: "accent" });
                              }
                          } else {
                              if (value13 != value23) {
                                  if (sortways[3] == "1") {
                                      //升序
                                      return a[sortfields[3]].localeCompare(b[sortfields[3]], "zh-Hans-CN", { sensitivity: "accent" });
                                  } else {
                                      //降序
                                      return b[sortfields[3]].localeCompare(a[sortfields[3]], "zh-Hans-CN", { sensitivity: "accent" });
                                  }
                              } else {
                                  if (sortways[4] == "1") {
                                      //升序
                                      return a[sortfields[4]].localeCompare(b[sortfields[4]], "zh-Hans-CN", { sensitivity: "accent" });
                                  } else {
                                      //降序
                                      return b[sortfields[4]].localeCompare(a[sortfields[4]], "zh-Hans-CN", { sensitivity: "accent" });
                                  }
                              }
                          }
                      }
                  }
              });
          } else {
              popdada.sort((a, b) => {
                  let value10 = a[sortfields[0]];
                  let value20 = b[sortfields[0]];
                  let value11 = a[sortfields[1]];
                  let value21 = b[sortfields[1]];
                  let value12 = a[sortfields[2]];
                  let value22 = b[sortfields[2]];
                  let value13 = a[sortfields[3]];
                  let value23 = b[sortfields[3]];
                  let value14 = a[sortfields[4]];
                  let value24 = b[sortfields[4]];
                  let value15 = a[sortfields[5]];
                  let value25 = b[sortfields[5]];
                  if (value10 != value20) {
                      if (sortways[0] == "1") {
                          //升序
                          return a[sortfields[0]].localeCompare(b[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      } else {
                          //降序
                          return b[sortfields[0]].localeCompare(a[sortfields[0]], "zh-Hans-CN", { sensitivity: "accent" });
                      }
                  } else {
                      if (value11 != value21) {
                          if (sortways[1] == "1") {
                              //升序
                              return a[sortfields[1]].localeCompare(b[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                          } else {
                              //降序
                              return b[sortfields[1]].localeCompare(a[sortfields[1]], "zh-Hans-CN", { sensitivity: "accent" });
                          }
                      } else {
                          if (value12 != value22) {
                              if (sortways[2] == "1") {
                                  //升序
                                  return a[sortfields[2]].localeCompare(b[sortfields[2]], "zh-Hans-CN", { sensitivity: "accent" });
                              } else {
                                  //降序
                                  return b[sortfields[2]].localeCompare(a[sortfields[2]], "zh-Hans-CN", { sensitivity: "accent" });
                              }
                          } else {
                              if (value13 != value23) {
                                  if (sortways[3] == "1") {
                                      //升序
                                      return a[sortfields[3]].localeCompare(b[sortfields[3]], "zh-Hans-CN", { sensitivity: "accent" });
                                  } else {
                                      //降序
                                      return b[sortfields[3]].localeCompare(a[sortfields[3]], "zh-Hans-CN", { sensitivity: "accent" });
                                  }
                              } else {
                                  if (value14 != value24) {
                                      if (sortways[4] == "1") {
                                          //升序
                                          return a[sortfields[4]].localeCompare(b[sortfields[4]], "zh-Hans-CN", { sensitivity: "accent" });
                                      } else {
                                          //降序
                                          return b[sortfields[4]].localeCompare(a[sortfields[4]], "zh-Hans-CN", { sensitivity: "accent" });
                                      }
                                  } else {
                                      if (sortways[5] == "1") {
                                          //升序
                                          return a[sortfields[5]].localeCompare(b[sortfields[5]], "zh-Hans-CN", { sensitivity: "accent" });
                                      } else {
                                          //降序
                                          return b[sortfields[5]].localeCompare(a[sortfields[5]], "zh-Hans-CN", { sensitivity: "accent" });
                                      }
                                  }
                              }
                          }
                      }
                  }
              });
          }
          this.sortdata = popdada;
      },
      btnquery() {
          this.loadAllData();
          // this.$refs.ddlCommonTable.commitProxy("query");
      },
      btnsel(chk) {
          this.$refs.ddlCommonTable.setAllSelection(chk);
      },
      btncancel() {
          this.$emit("cancel");
      },
      btnok() {
          this.qcode = "";
          this.autosearch();
          setTimeout(() => {
              this.$emit("selitem", this.$refs.ddlCommonTable.getSelectRecords());
          }, 80);
      },
      clkselect(s) {
          // console.log("sss", s);
      },
      loadAllData: function () {
          this.loading = true;
          this.$ddldata
              .getallrptitem()
              .then((res) => {
                  //this.setcol();
                  this.qcode = "";
                  this.$refs.qcodeinput.focus();
                  if (this.$refs.ddlCommonTable) {
                      this.$refs.ddlCommonTable.commitProxy("query");
                  }
                  this.loading = false;
              })
              .catch((e) => {
                  console.log("erro", e);
              });
      },
      refreshdata: function () {
          this.$ddldata.rmallrptitem = "";
          this.loadAllData();
      },
  },
};
</script>
